package com.xyhy.core.jackson.serial;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

public class MoneySerializer extends StdSerializer<Integer> {
  private static final long serialVersionUID = 1L;

  public MoneySerializer() {
    super(Integer.class);
  }

  @Override
  public void serialize(Integer value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    if (null != value) {
      jgen.writeNumber(1.0f * value / 100);
    } else {
      jgen.writeNull();
    }
  }

}